package com.bang.study.jvm.oom;

/**
 * @Auther: Bang
 * @Date: 2019/9/28 12:58
 * @Description: java虚拟机栈溢出
 * @VM: -Xss2m
 */
public class JavaVmStackOOM {

    private void dontStop() {
        while (true) {

        }
    }

    public void stackLeakByThread() {
        while (true) {
            Thread thread = new Thread(new Runnable() {
                @Override
                public void run() {
                    System.out.println(Thread.currentThread().getName());
                    dontStop();
                }
            });
            thread.start();
        }
    }

    public static void main(String[] args) {
        JavaVmStackOOM oom = new JavaVmStackOOM();
        oom.stackLeakByThread();
    }
}
